package com.homson.coreservice.servicecommon.utils;


import java.util.Optional;

public class EnumUtils {
    
    public static <T extends Enum<T>> Optional<T> of(Class<T> enumClass, String name) {
        if (enumClass == null || name == null) {
            return Optional.empty();
        }
        
        try {
            return Optional.of(Enum.valueOf(enumClass, name));
        } catch (IllegalArgumentException e) {
            return Optional.empty();
        }
    }
}
